If a is your text frame and b you graphics frame, it comes down to
a.select (); // SelectionOptions.REPLACE_WITH is the default
You can set the text alignment of the text frame to centered, but not that of the graphics frame -- it's a text only attribute (to be precise, a Paragraph property). Given the selection above, of a text frame and a rectangle (ID doesn't care if it contains a graphic or not, as long as it does not contain text),
app.selection.paragraphs.everyItem().justification = Justification.CENTER_ALIGN;
sets the paragraph alignment for the text in frame (a) but -- rather obviously -- not in frame (b).